
//------method for Dojo
//------tc tang

//--for Dojo Show Pannel
function OpenCenteredPannel(url,handle,local){
  var tempHandle = null;
  if(local){
    //show local pannel
    if(handle){
      handle.setUrl(url);
      handle.show();
    }else{
      frameDlg.setUrl(url);
      frameDlg.show();
    }
  }else{
    //show remote pannel
    if(handle){
      handle.setUrl(url);
      handle.show();
    }else{
      frameRemoteDlg.setUrl(url);
      frameRemoteDlg.show();
    }
  }
}

//---for submit Form
submitForm = function(form,fcallBack,fError){
	  var kw = {
	                mimetype: "text/plain",
					formNode: form,
					load: function(t, txt, e) {
						  //dojoSetValue("DialogContent",txt);
						  if(typeof(fcallBack)!="function"){
						    fcallBack = new Function();
						  }
						  fcallBack(txt);
						  
					},
					error: function(t, e) {
						//dojo.debug("Error!... " + e.message);
						if(typeof(fError)!="function"){
						  fError = new Function();
						}
						fError();
					}
				};
				dojo.io.bind(kw);
				return false;
	}

//--set Dim Value--
setPannelValue = function(txt,pannelName){ 
 if(!pannelName){
   pannelName="DialogContent";//default
 }
 var ele= document.getElementById(pannelName);
 if(!ele){
   return false;
 }
 var ele_childs = ele.getElementsByTagName("DIV");
 for(i=0;i<ele_childs.length;i++){
    if(ele_childs[i].getAttribute("dojoattachpoint")=="containerNode"){
       ele_childs[i].innerHTML = txt;
    }
 }
}

//------for dim----------------
var scrollStatus="no";
showDim = function(url){
 dimDlg.setBackgroundOpacity();
 dimDlg.showBackground();
 var body = document.getElementsByTagName("BODY");
 scrollStatus=body[0].scroll;
 body[0].scroll="no";//FOR DOJO IE BUG
 body[0].scrollTop=0;
}
hideDim = function(){
 dimDlg.hide();
 var body = document.getElementsByTagName("BODY");
 body[0].scroll=scrollStatus;//FOR DOJO IE BUG 
}

//-----------------------------------------------------------------
/**
   this method for delay init dojo untill call dojo function
*/

var initDojoFramework = false;

dojoProxy = function(targetElementName,proxyInstanceName){
   var dojoObj = null;
   var func=null;
   
   this._call = function(){
     if(!initDojoFramework){
       setTimeout(proxyInstanceName+"._call()",1000);
     }else{
       this._init();
       eval(func);
     }
   }
   
   this._init = function(){
     dojoObj=dojo.widget.byId(targetElementName);
   }
   
   this.show = function(){
     func = 'dojoObj.show()';
     this._call();
   }
   
   this.hide = function(){
     func = 'dojoObj.hide()';
     this._call();
   }
   
   this.refresh = function(){
     func = 'dojoObj.refresh()';
     this._call();
   }
   
   this.loadContents = function(){
     func = 'dojoObj.loadContents()';
     this._call();
   }
   
   this.setUrl = function(url){
     func = "dojoObj.setUrl('"+url+"')";
     this._call();
   }
   
   this.onLoad = function(e){
     func = "dojoObj.onLoad('"+e+"')";
     this._call();
   }
   
   this.onUnLoad = function(e){
     func = "dojoObj.onUnLoad('"+e+"')";
     this._call();
   }
   
  this.setContent = function(/*string*/data){
     func = "dojoObj.setContent('"+data+"')";
     this._call();
  } 
}